package com.xn.app.muying.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;

import com.xn.app.muying.LianJieActivity;
import com.xn.app.muying.MainActivity;
import com.xn.app.muying.R;
import com.xn.app.muying.TaiXinLieBiaoActivity;
import com.xn.app.muying.util.Constants;
import com.xn.app.muying.util.ToastUtil;

/**
 * A simple {@link Fragment} subclass.
 */
public class MonitorFragment extends Fragment {
    Button jian_hu, cha_kan;
    boolean isLogin=false;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        isLogin= Constants.getBooleanByName(MainActivity.mActivity,"isLogin");
        LinearLayout jiance = (LinearLayout) inflater.inflate(R.layout.fragment_jian_ce, container, false);
        jian_hu = (Button) jiance.findViewById(R.id.jian_hu);
        cha_kan = (Button) jiance.findViewById(R.id.cha_kan);
        jian_hu.setOnClickListener(onClickListener);
        cha_kan.setOnClickListener(onClickListener);
        return jiance;
    }

    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.jian_hu:
                   if (isLogin){
                       MainActivity.mActivity.startActivity(new Intent(MainActivity.mActivity, LianJieActivity.class));
                   }else{
                       ToastUtil.showToast(MainActivity.mActivity,"您还没有登录，登录后更精彩！");
                   }

                    break;
                case R.id.cha_kan:
                    if (isLogin){
                        MainActivity.mActivity.startActivity(new Intent(MainActivity.mActivity, TaiXinLieBiaoActivity.class));
                    }else{
                        ToastUtil.showToast(MainActivity.mActivity,"您还没有登录，登录后更精彩！");
                    }
                    break;
            }
        }
    };
}
